﻿@model BskLeague.Models.AnnounceCommunicate

@{
    ViewBag.Title = "Formularz zgłoszenia drużyny";
}

      


      
<script type="text/javascript">


var announceCost = new Array();

@{   
 string message=""; 
 
 }
        @if (ViewBag.Costs!=null){
            for (int i = 0; i < 20; i++) {
                message += "announceCost[" + i + "]=\"" + ViewBag.Costs[i] + "\";";
            

            @MvcHtmlString.Create(message);
                                      }
                                      }



    

    $(document).ready(function () {
        var count = 0;

        $("#numberOfPlayers").change(function () {
            var selectedNumber = parseInt($("#numberOfPlayers option:selected").val());
            //    alert('porownanie dla zaznaczonego:' + selectedNumber + ' oraz count: ' + count);
            if (selectedNumber < count) {
                //    alert('trzeba usuwac');
                for (var i = count - 1; i >= selectedNumber; i--) {
                   // $('#playerFieldset' + i).fadeOut(2000);
                   // var t = setTimeout("$('#playerFieldset' + i).remove()", 2000);
                    $('#playerFieldset' + i).remove();
                }
            }

            if (selectedNumber > count) {
                //    alert('trzeba dodawac pola');
                for (var i = count; i < selectedNumber; i++) {
                    $('<fieldset />').attr({ 'id': 'playerFieldset' + i, 'style': 'display: inline; margin: 1em 1em 1.5em 0;' }).appendTo('#playersField').insertBefore('#submitP').hide().fadeIn(2000);
                    $('<legend />').text("Gracz " + (i + 1)).appendTo('#playerFieldset' + i);
                    $('<div />').attr({ 'class': 'editor-label' }).add($('<label />').attr({ 'for': 'Players_' + i + '__Name' + i }).text("Name")).appendTo('#playerFieldset' + i);
                    $('<div />').attr({ 'class': 'editor-field' }).add($('<input />').attr({ 'class': 'text-box single-line'
					 , 'id': 'Players_' + i + '__Name'
					 , 'name': 'Players[' + i + '].Name'
					 , 'type': 'text'
					 , 'value': ''
                    })).appendTo('#playerFieldset' + i);


                    $('<div />').attr({ 'class': 'editor-label' }).add($('<label />').attr({ 'for': 'Players_' + i + '__Surame' + i }).text("Surname")).appendTo('#playerFieldset' + i);
                    $('<div />').attr({ 'class': 'editor-field' }).add($('<input />').attr({ 'class': 'text-box single-line'
					 , 'id': 'Players_' + i + '__Surname'
					 , 'name': 'Players[' + i + '].Surname'
					 , 'type': 'text'
					 , 'value': ''
                    })).appendTo('#playerFieldset' + i);


                    $('<div />').attr({ 'class': 'editor-label' }).add($('<label />').attr({ 'for': 'Players_' + i + '__Email' + i }).text("Email")).appendTo('#playerFieldset' + i);
                    $('<div />').attr({ 'class': 'editor-field' }).add($('<input />').attr({ 'class': 'text-box single-line'
					 , 'id': 'Players_' + i + '__Email'
					 , 'name': 'Players[' + i + '].Email'
					 , 'type': 'text'
					 , 'value': ''
                    })).appendTo('#playerFieldset' + i);

                    $('<div />').attr({ 'class': 'editor-label' }).add($('<label />').attr({ 'for': 'Players_' + i + '__LicenceId' + i }).text("LicenceId")).appendTo('#playerFieldset' + i);
                    $('<div />').attr({ 'class': 'editor-field' }).add($('<input />').attr({ 'class': 'text-box single-line'
					 , 'id': 'Players_' + i + '__LicenceId'
					 , 'name': 'Players[' + i + '].LicenceId'
					 , 'type': 'text'
					 , 'value': ''
                    })).appendTo('#playerFieldset' + i);


                    $('<div />').attr({ 'class': 'editor-label' }).add($('<label />').attr({ 'for': 'ChefPlayerIndex' }).text("Czy jest szefem?")).appendTo('#playerFieldset' + i);
                    $('<div />').attr({ 'class': 'editor-field' }).add($('<input />').attr({ 'checked': 'True'
					 , 'data-val': 'True'
					 , 'data-val-number': 'The field ChefPlayerIndex must be a number.'
					 , 'data-val-required': 'The ChefPlayerIndex field is required.'
					 , 'id': 'ChefPlayerIndex'
					 , 'name': 'ChefPlayerIndex'
					 , 'name': 'ChefPlayerIndex'
					 , 'type': 'radio'
					 , 'value': '0'
                    })).appendTo('#playerFieldset' + i);
                }
            }
            count = selectedNumber;
            $('#costP').text('Cena ' + announceCost[count]);

        });
    });
	   
</script>


@using (Html.BeginForm("Index", "Announce", FormMethod.Post, new { enctype = "multipart/form-data" })) {
    @Html.ValidationSummary(true)

        
        @Html.HiddenFor(model => model.AnnounceCommunicateId)
        //@Html.HiddenFor(Model => Model.AnnounceDate)

        <fieldset id="playersField">
        <legend>Formularz zgłoszeniowy</legend>
        
        <fieldset>
        <legend>Dane drużyny</legend>
        <div class="editor-label">
            <label for="TeamName">TeamName</label>
        </div>
        <div class="editor-field">
            <input class="text-box single-line" id="TeamName" name="TeamName" type="text" value=""/>
           
			<select name="mydropdown" id="numberOfPlayers">
				<option value="0">Ilość zawodników</option>	
                <option value="1">1</option>
                <option value="2">2</option>
				<option value="6">6</option>
				<option value="7">7</option>
				<option value="8">8</option>
				<option value="9">9</option>
				<option value="10">10</option>
				<option value="11">11</option>
				<option value="12">12</option>
				<option value="13">13</option>
				<option value="14">14</option>
			</select>
			<div class="cost-label" >
			<p id="costP">Koszt zgłoszenia:</p>
			</div>
		
			
			
			
        </div>
        </fieldset>
		<br/>


        <p id="submitP">
            <input type="submit" value="Prześlij" id="submitButton" />
        </p>
    </fieldset>

   

       
        


        
    
}


